package com.chushouya.order.constants;

import com.general.framework.core.enums.IEnum;

import java.util.Objects;

/**
 * 旧衣重量范围枚举
 */
public enum ClothesWeightRangeEnum implements IEnum<Integer> {

    RANGE_8_10KG(1, "8-10kg", "约20件"),
    RANGE_20KG(2, "20kg", "约40件"),
    RANGE_20_50KG(3, "20-50kg", "约60件"),
    RANGE_ABOVE_50KG(4, "50kg以上", "约150件");

    private Integer value;
    private String weightRange;
    private String pieceCount;

    ClothesWeightRangeEnum(Integer value, String weightRange, String pieceCount) {
        this.value = value;
        this.weightRange = weightRange;
        this.pieceCount = pieceCount;
    }

    public static String getWeightRange(Integer value) {
        for (ClothesWeightRangeEnum thisEnum : ClothesWeightRangeEnum.values()) {
            if (Objects.equals(thisEnum.value, value)) {
                return thisEnum.weightRange;
            }
        }
        return ClothesWeightRangeEnum.RANGE_8_10KG.weightRange;
    }

    public static String getPieceCount(Integer value) {
        for (ClothesWeightRangeEnum thisEnum : ClothesWeightRangeEnum.values()) {
            if (Objects.equals(thisEnum.value, value)) {
                return thisEnum.pieceCount;
            }
        }
        return ClothesWeightRangeEnum.RANGE_8_10KG.pieceCount;
    }

    public static ClothesWeightRangeEnum get(Integer value) {
        for (ClothesWeightRangeEnum thisEnum : ClothesWeightRangeEnum.values()) {
            if (Objects.equals(thisEnum.value, value)) {
                return thisEnum;
            }
        }
        return ClothesWeightRangeEnum.RANGE_8_10KG;
    }

    /**
     * 获取完整描述
     */
    public String getFullDesc() {
        return this.weightRange + " " + this.pieceCount;
    }

    @Override
    public Integer value() {
        return this.value;
    }

    @Override
    public String named() {
        return this.weightRange;
    }

    public String getWeightRange() {
        return weightRange;
    }

    public String getPieceCount() {
        return pieceCount;
    }
}
